package com.ruoyi.web.controller.dmpdolphinscheduler;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dmpdolphinscheduler.domain.DmpDolphinschedulerConfig;
import com.ruoyi.dmpdolphinscheduler.service.IDmpDolphinschedulerConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * DS调度系统配置Controller
 * 
 * @author MquanZeng
 * @date 2021-12-31
 */
@RestController
@RequestMapping("/dmpdolphinscheduler/config")
public class DmpDolphinschedulerConfigController extends BaseController
{
    @Autowired
    private IDmpDolphinschedulerConfigService dmpDolphinschedulerConfigService;

    /**
     * 查询DS调度系统配置列表
     */
    @PreAuthorize("@ss.hasPermi('dmpdolphinscheduler:config:list')")
    @GetMapping("/list")
    public TableDataInfo list(DmpDolphinschedulerConfig dmpDolphinschedulerConfig)
    {
        startPage();
        List<DmpDolphinschedulerConfig> list = dmpDolphinschedulerConfigService.selectDmpDolphinschedulerConfigList(dmpDolphinschedulerConfig);
        return getDataTable(list);
    }

    /**
     * 导出DS调度系统配置列表
     */
    @PreAuthorize("@ss.hasPermi('dmpdolphinscheduler:config:export')")
    @Log(title = "DS调度系统配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DmpDolphinschedulerConfig dmpDolphinschedulerConfig)
    {
        List<DmpDolphinschedulerConfig> list = dmpDolphinschedulerConfigService.selectDmpDolphinschedulerConfigList(dmpDolphinschedulerConfig);
        ExcelUtil<DmpDolphinschedulerConfig> util = new ExcelUtil<DmpDolphinschedulerConfig>(DmpDolphinschedulerConfig.class);
        util.exportExcel(response, list, "DS调度系统配置数据");
    }

    /**
     * 获取DS调度系统配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('dmpdolphinscheduler:config:query')")
    @GetMapping(value = "/{dolsId}")
    public AjaxResult getInfo(@PathVariable("dolsId") Long dolsId)
    {
        return AjaxResult.success(dmpDolphinschedulerConfigService.selectDmpDolphinschedulerConfigByDolsId(dolsId));
    }

    /**
     * 新增DS调度系统配置
     */
    @PreAuthorize("@ss.hasPermi('dmpdolphinscheduler:config:add')")
    @Log(title = "DS调度系统配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DmpDolphinschedulerConfig dmpDolphinschedulerConfig)
    {
        return toAjax(dmpDolphinschedulerConfigService.insertDmpDolphinschedulerConfig(dmpDolphinschedulerConfig));
    }

    /**
     * 修改DS调度系统配置
     */
    @PreAuthorize("@ss.hasPermi('dmpdolphinscheduler:config:edit')")
    @Log(title = "DS调度系统配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DmpDolphinschedulerConfig dmpDolphinschedulerConfig)
    {
        return toAjax(dmpDolphinschedulerConfigService.updateDmpDolphinschedulerConfig(dmpDolphinschedulerConfig));
    }

    /**
     * 删除DS调度系统配置
     */
    @PreAuthorize("@ss.hasPermi('dmpdolphinscheduler:config:remove')")
    @Log(title = "DS调度系统配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dolsIds}")
    public AjaxResult remove(@PathVariable Long[] dolsIds)
    {
        return toAjax(dmpDolphinschedulerConfigService.deleteDmpDolphinschedulerConfigByDolsIds(dolsIds));
    }

    /**
     * 获取DS调度系统下拉项
     */
    @GetMapping("/selectDolSdrList")
    public AjaxResult selectDolSdrList()
    {
        return AjaxResult.success(dmpDolphinschedulerConfigService.getDolSdrOptions());
    }
}
